package com.tree.thrive.adapter.openapi;

import com.tree.thrive.business.el.service.SpringELService;
import com.tree.thrive.business.input.domain.req.InputCheckReq;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * top-tree
 *
 * @Auther: cheng.tang
 * @Date: 2022/7/12 3:19 PM
 * @Description:
 */
@RestController
@Slf4j
public class SpringELController {

    @Autowired
    private SpringELService springELService;

    @Operation(tags = "springEl表达式中的参数时数组")
    @GetMapping("/spring_el/args/list")
    public String withSpringELArray() {
        InputCheckReq inputCheckReq = new InputCheckReq();
        inputCheckReq.setName("springElListName");
        inputCheckReq.setNote("springElListNote");
        List<InputCheckReq> list = new ArrayList<>();
        list.add(inputCheckReq);
        springELService.springELArray(list);
        return "success";
    }

    /**
     * inputCheckReq {"name":"springElListName","note":"springElListNote"}
     * lockPath Lock:springElListNote:springElListName
     *
     * @return
     */
    @Operation(tags = "springEl表达式中的参数对象中的方法")
    @GetMapping("/spring_el/args/method")
    public String withSpringELArgsMethod() {
        InputCheckReq inputCheckReq = new InputCheckReq();
        inputCheckReq.setName("springElListName");
        inputCheckReq.setNote("springElListNote");
        springELService.springELArgsMethod(inputCheckReq);
        return "success";
    }


}
